# Maintainer: Brett Cornwall <ainola@archlinux.org>

pkgname=seatd
pkgver=0.8.0
pkgrel=1
pkgdesc="A minimal seat management daemon, and a universal seat management library"
arch=(loong64 x86_64)
url="https://sr.ht/~kennylevinsen/seatd/"
license=('MIT')
provides=("libseat.so")
replaces=("libseat")
makedepends=(
    'meson'
    'ninja'
    'scdoc'
    'systemd'
)
depends=(
    'systemd-libs'
)
source=(
    "$pkgname-$pkgver.tar.gz::https://git.sr.ht/~kennylevinsen/seatd/archive/$pkgver.tar.gz"
    "sysuser.conf"
)
sha256sums=('a562a44ee33ccb20954a1c1ec9a90ecb2db7a07ad6b18d0ac904328efbcf65a0'
            'e833292adf5da25b5258a5209c258f0e4c12e1d6fe81cf228fd0cfb575080d78')
build() {
    mkdir build
    meson --prefix=/usr \
          --buildtype=plain \
          -Dexamples="disabled" \
          -Dserver="enabled" \
          -Dlibseat-logind="systemd" \
          -Dman-pages="enabled" \
          "seatd-$pkgver" \
          build
    ninja -C build
}

check() {
    ninja -C build test
}

package() {
    DESTDIR="$pkgdir/" ninja -C build install
    install -Dm644 "seatd-$pkgver/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"

    # Allow users in the "seat" group to access seatd, and provide a service
    # that will be necessary for e.g. wlroots-based seat management
    install -Dm644 "seatd-$pkgver/contrib/systemd/seatd.service" \
            -t "$pkgdir/usr/lib/systemd/system/"
    install -Dm644 "sysuser.conf" "$pkgdir/usr/lib/sysusers.d/seatd.conf"
}
